using System.ComponentModel.DataAnnotations;

namespace CoreManager.Models.DTOs
{
    /// <summary>
    /// 登录请求DTO
    /// </summary>
    public class LoginDto
    {
        /// <summary>
        /// 用户名
        /// </summary>
        [Required(ErrorMessage = "用户名不能为空")]
        public string UserName { get; set; } = string.Empty;

        /// <summary>
        /// 密码
        /// </summary>
        [Required(ErrorMessage = "密码不能为空")]
        public string Password { get; set; } = string.Empty;

        /// <summary>
        /// 验证码
        /// </summary>
        public string CaptchaCode { get; set; } = string.Empty;

        /// <summary>
        /// 验证码请求ID
        /// </summary>
        public string RequestId { get; set; } = string.Empty;

        /// <summary>
        /// 登录响应DTO
        /// </summary>
        public class LoginResultDto
        {
            /// <summary>
            /// 访问令牌
            /// </summary>
            public string AccessToken { get; set; } = string.Empty;

            /// <summary>
            /// 刷新令牌
            /// </summary>
            public string RefreshToken { get; set; } = string.Empty;

            /// <summary>
            /// 过期时间
            /// </summary>
            public DateTime Expires { get; set; }

            /// <summary>
            /// 用户信息
            /// </summary>
            public UserInfoDto? UserInfo { get; set; }
        }

        /// <summary>
        /// 用户信息DTO
        /// </summary>
        public class UserInfoDto
        {
            /// <summary>
            /// 用户ID
            /// </summary>
            public int Id { get; set; }

            /// <summary>
            /// 用户名
            /// </summary>
            public string UserName { get; set; } = string.Empty;

            /// <summary>
            /// 真实姓名
            /// </summary>
            public string? RealName { get; set; }

            /// <summary>
            /// 邮箱
            /// </summary>
            public string? Email { get; set; }

            /// <summary>
            /// 手机号
            /// </summary>
            public string? Phone { get; set; }

            /// <summary>
            /// 头像
            /// </summary>
            public string? Avatar { get; set; }

            /// <summary>
            /// 角色列表
            /// </summary>
            public List<string> Roles { get; set; } = new();

            /// <summary>
            /// 权限列表
            /// </summary>
            public List<string> Permissions { get; set; } = new();
        }
    }
}